
*** Set up directories

global data ** folder with data **
global figures ** folder for figures **

cd $data

/***************************************************
	Figure 1
*****************************************************/
	
use $data/figures_1_2.dta, clear

	gr twoway line married year if educ == "scol",  lcolor(g9) lcolor(gs9) || ///
	connected married year if educ == "lths",  lcolor(gs9) mcolor(gs9) lp(solid) msym(o)  || ///
	connected relwage year if educ == "lths" , lcolor(black) lpattern(solid)   msym(o) mcolor(black) scheme(s1mono) ///
	 xlabel(1960(5)2010) ytitle("Relative Wage, Fraction Married") xtitle("Year") || ///  
	line relwage year if educ == "scol", lcolor(black) ///
	legend(order(1 4 2 3) label(3 "Rel. Wage, <=HS") label(4 "Rel. Wage, >HS") label(1 "Married, >HS") label(2 "Married, <=HS")) /// 
	ylabel(,grid gstyle(major) glcolor(gs14) glwidth(vthin)) xline(1980, lp(dash) lcolor(gs11) lw(thin)) ///
	xlabel(1960(10)2010) xtitle("")
	

	gr export $figures/figure1.eps , replace
	cd $figures
	!ps2pdf -dEPSCrop $figures/figure1.eps
	!rm -f $figures/figure1.eps
	cd $dofiles
	
	


/***************************************************
	Figure 2
*****************************************************/

use $data/figures_1_2.dta, clear


	gr twoway line lnnewhrwagefem year if educ == "scol",  lpattern(dash) lcolor(black) || /// 
	connected lnnewhrwagefem year if educ == "lths" , lcolor(black) msym(Oh) mcolor(black) lpattern(dash) scheme(s1mono) ///
	|| line lnnewhrwagemale year if educ == "scol", lcolor(black) || /// 
	connected lnnewhrwagemale year if educ == "lths" , lcolor(black) lpattern(solid) msym(O) mcolor(black) ///
	legend(label(1 ">HS, Fem") label(2 "<=HS, Fem") label(3 ">HS, Male") label(4 "<=HS, Male")) xlabel(1960(5)2010) ytitle("Change in Ln Fem., Male Wage from 1980, $2012") xtitle("") yline(0, lpattern(dot) lcolor(black)) /// 
	ylabel(,grid gstyle(major) glcolor(gs14) glwidth(vthin)) xlabel(1960(10)2010)
	
	gr export $figures/figure2.eps , replace
	cd $figures
	!ps2pdf -dEPSCrop $figures/figure2.eps
	!rm -f $figures/figure2.eps
	cd $dofiles
	
	
/****************************************************
	FIGURE 3
******************************************************/

use $data/firststage.dta, clear

	drop if race == "oth" 

	collapse lncpsfemwage  lncpsmalewage  lncpsrelwage [aweight=cps_pop], by(fipstate id year)
	
	drop if fipstate ==2 | fipstate ==15 // drop alaska and hawaii - too hard to graph
	
	reshape wide lncpsfemwage  lncpsmalewage  lncpsrelwage, i(id fipstate) j(year)
	
	rename fipstate statefip
	
	gen growth8010 = lncpsrelwage2010-lncpsrelwage1980
	gen growthfem8010 = lncpsfemwage2010 - lncpsfemwage1980
	gen growthmale8010 =  lncpsmalewage2010 -  lncpsmalewage1980
	
	foreach x in growth8010 growthfem8010 growthmale8010 {
	
	if "`x'" == "growth8010" local fcolor Greys
	if "`x'" != "growth8010" local fcolor Reds
	if "`x'" =="growth8010" local clbreaks " clmethod(custom) clbreaks( .05 .11 .17 .23 .28)"
	*if "`x'" != "growth8010" local clbreaks " clmethod(custom) clbreaks( -.1 0 .1 .2 .3 .4 .5)"
	if "`x'" != "growth8010" local clbreaks " clmethod(custom) clbreaks( 0.8 1 1.1 1.2 1.3 1.4 1.6)"
	
		spmap `x' using "$data/states", id(id) fcolor(`fcolor') `clbreaks' legend(symy(*2) symx(*2) size(*2))
	
	if "`x'" == "growth8010" local out 3
	if "`x'" == "growthfem8010" local out a2_a
	if "`x'" == "growthmale8010" local out a2_b
	
		graph export "$figures/figure`out'.eps", replace	
		cd $figures
		!ps2pdf -dEPSCrop  "$figures/figure`out'.eps"
		!rm -f "$figures/figure`out'.eps"
		cd $logs
	
	}
	

/*******************************************************
	FIGURE A1
*****************************************************/

use $data/figurea1, clear
	
	gr twoway line married year if educ_4 == "scol",  lcolor("132 206 160") lcolor("132 206 160") || ///
	connected married year if educ_4 == "col",  lcolor("132 206 160") mcolor("132 206 160") lp(solid) msym(o)  || ///
	connected relwage year if educ_4 == "col" , lcolor(purple) lpattern(solid)  msym(o) mcolor(purple) scheme(s1mono) ///
	 xlabel(1960(5)2010) ytitle("Relative Wage, Fraction Married") xtitle("Year") || ///  
	line relwage year if educ_4 == "scol", lcolor(purple) ///
	legend(order(1 4 2 3) label(3 "Rel. Wage, College") label(4 "Rel. Wage, Some College") label(1 "Married, Some College") label(2 "Married, College")) ylabel(,grid gstyle(major) glcolor(gs14) glwidth(vthin)) xline(1980, lp(dash) lcolor(gs11) lw(thin)) ///
	xlabel(1960(10)2010) xtitle("")
	

	gr export $figures/figurea1_b.eps , replace
	cd $figures
	!ps2pdf -dEPSCrop $figures/figurea1_b.eps
	!rm -f $figures/figurea1_b.eps
	cd $dofiles	
	
	
	gr twoway line married year if educ_4 == "lths",  lcolor("132 206 160") lcolor("132 206 160") || ///
	connected married year if educ_4 == "hs",  lcolor("132 206 160") mcolor("132 206 160") lp(solid) msym(o)  || ///
	connected relwage year if educ_4 == "hs" , lcolor(purple) lpattern(solid)  msym(o) mcolor(purple) scheme(s1mono) ///
	 xlabel(1960(5)2010) ytitle("Relative Wage, Fraction Married") xtitle("Year") || ///  
	line relwage year if educ_4 == "lths", lcolor(purple) ///
	legend(order(1 4 2 3) label(3 "Rel. Wage, HS") label(4 "Rel. Wage, < HS") label(1 "Married, < HS") label(2 "Married, HS")) ylabel(,grid gstyle(major) glcolor(gs14) glwidth(vthin)) xline(1980, lp(dash) lcolor(gs11) lw(thin)) ///
	xlabel(1960(10)2010) xtitle("")
	

	gr export $figures/figurea1_a.eps , replace
	cd $figures
	!ps2pdf -dEPSCrop $figures/figurea1_a.eps
	!rm -f $figures/figurea1_a.eps
	cd $dofiles		
	
	
	